package dRegAut.opg2;


/**
 * Martin 2.55 (figure 2.45a page 87)
 *
 * @author Michael B. Mogensen
 */
public class O2_6 {

    public FA createFA() {
        FA fa = new FA();
        State state1 = new State("1");
        State state2 = new State("2");
        State state3 = new State("3");
        State state4 = new State("4");
        State state5 = new State("5");

        fa.alphabet = new Alphabet("ab");

        fa.states.add(state1);
        fa.states.add(state2);
        fa.states.add(state3);
        fa.states.add(state4);
        fa.states.add(state5);

        fa.initial = state1;
        fa.accept.add(state5);

        fa.setTransition(state1, 'a', state2);
        fa.setTransition(state1, 'b', state3);

        fa.setTransition(state2, 'a', state3);
        fa.setTransition(state2, 'b', state5);

        fa.setTransition(state3, 'a', state4);
        fa.setTransition(state3, 'b', state3);

        fa.setTransition(state4, 'a', state3);
        fa.setTransition(state4, 'b', state5);

        fa.setTransition(state5, 'a', state2);
        fa.setTransition(state5, 'b', state5);

        return fa;
	}
}
